package main

import (
	"context"
	"fmt"
	"log"

	"gitee.com/go-course/go12/vblog/apps/comment"
	"google.golang.org/grpc"
	"google.golang.org/grpc/credentials/insecure"
)

func main() {
	//
	// 1. grpc.Dial负责和gRPC服务建立链接
	conn, err := grpc.Dial("localhost:1234",
		grpc.WithTransportCredentials(insecure.NewCredentials()))
	if err != nil {
		log.Fatal(err)
	}
	defer conn.Close()

	cc := comment.NewRPCClient(conn)
	resp, err := cc.CreateComment(context.Background(),
		&comment.CreateCommentRequest{UserId: "1", Content: "test"})
	if err != nil {
		panic(err)
	}
	fmt.Println(resp)
}
